package com.briup.ch11;

import java.io.*;

/**
 * @author yuxi
 * @version 1.0
 * @date 2025/10/16
 * @Description:
 */
public class Test14_Charset {
    public static void main(String[] args) throws IOException {
        FileInputStream fileInputStream = new FileInputStream("test.txt");
        InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream,"UTF-8");
        System.out.println(inputStreamReader.getEncoding());
        BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
        String line = null;
        while ((line = bufferedReader.readLine())!= null) {
            System.out.println(line);
        }
        inputStreamReader.close();
        fileInputStream.close();
        FileOutputStream fileOutputStream = new FileOutputStream("test.txt",true);
        OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream,"UTF-8");
        outputStreamWriter.write("你好，世界！");
        outputStreamWriter.close();
        fileOutputStream.close();

    }
}
